package com.my.pojo;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.List;

/**
 * @Author: jiChen
 * @Description: 商品信息实体类
 * @Date: 2021/11/29 8:16 上午
 */

@Entity
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Table(name = "goods")
public class Goods {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "goods_id")
    private Integer goodsId;

    @Column(name = "name")
    private String name;

    @Column(name = "price")
    private Double price;

    @Column(name = "img_url",columnDefinition = "LONGBLOB")
    private String imgUrl;

    @Column(name = "stock")
    private int stock;

    @Column(name = "info")
    private String info;

    @Column(name = "status")
    private Integer status;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "business_id")
    private Business business;

    @OneToMany(mappedBy = "address")
    private List<Orders> ordersList;

    @OneToMany(mappedBy = "goods")
    private List<Stock> stockList;

    @OneToMany(mappedBy = "goods")
    private List<ShopCart> shopCartList;
}
